package com.simple.core.config.mdc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.task.TaskExecutorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MDCThreadPoolTaskExecutorConfiguration {

    @Autowired
    private TaskExecutorBuilder taskExecutorBuilder;

    @Bean("mdcThreadPoolTaskExecutor")
    @ConditionalOnMissingBean
    public MDCThreadPoolTaskExecutor mdcThreadPoolTaskExecutor() {
        return this.taskExecutorBuilder.build(MDCThreadPoolTaskExecutor.class);
    }
}
